{%- if storeConfig.yahoo_pixel_id -%}
        <!-- Yahoo Dot -->
    <script>(function (w, d, t, r, u) {
            w[u] = w[u] || [];
            w[u].push({'projectId': '{{ storeConfig.yahoo_projectid }}', 'properties': {'pixelId': '{{ storeConfig.yahoo_pixel_id }}'}});
            var s = d.createElement(t);
            s.src = r;
            s.async = true;
            s.onload = s.onreadystatechange = function () {
                var y, rs = this.readyState, c = w[u];
                if (rs && rs != "complete" && rs != "loaded") {
                    return
                }
                try {
                    y = YAHOO.ywa.I13N.fireBeacon;
                    w[u] = [];
                    w[u].push = function (p) {
                        y([p])
                    };
                    y(c)
                } catch (e) {
                }
            };
            var scr = d.getElementsByTagName(t)[0], par = scr.parentNode;
            par.insertBefore(s, scr)
        })(window, document, "script", "https://s.yimg.com/wi/ytc.js", "dotq");</script>

    {%- if template == 'product_detail' -%}
        <script>
            window.dotq = window.dotq || [];
            window.dotq.push({
                'projectId': '{{ storeConfig.yahoo_projectid }}',
                'properties': {
                    'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                    'qstrings': {
                        'et': 'custom',
                        'ea': 'ViewProduct',
						'ec': '{{ product.product_type | escape | append: ' '}}'.replace(/\s+$/g, ""),
                        'ev': 1,
                        'gv': '{{ product.variant.price }}',
                        'product_id': '{{ product.spu | escape}}',
                    }
                }
            }); </script>
    {%- elsif controller == 'order' and action == 'success' -%}
        <script>
            window.dotq = window.dotq || [];
            {%- for product in order.products -%}
            window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
            'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
            'qstrings': {
            'et': 'custom',
            'ea': 'Purchase',
			'ec': '{{ product.product_type | escape | append: ' '}}'.replace(/\s+$/g, ""),
            {%- if storeConfig.yahoo_enable_ga -%}
            'gv': "{{ order.current_subtotal_price| plus: order.current_coupon_price| plus: order.current_promotion_price }}",
            {%- else -%}
            'gv': '{{ order.total_price }}',
            {%- endif -%}
			'ev': '{{ product.quantity }}',
            'product_id': '{{ product.spu | escape}}'
            }
            }
            });
            {%- endfor -%}
        </script>
        {%- elsif template == 'search_detail' and search -%}
        <script>
        window.dotq = window.dotq || [];
        window.dotq.push({
        'projectId': '{{ storeConfig.yahoo_projectid }}',
        'properties': {
        'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
        'qstrings': {
        'et': 'custom',
        'ea': '{{template}}',
        'el': '{{ search.keywords | escape | append: ' '}}'.replace(/\s+$/g, "")
        }
        }
        }); </script>

        {%- elsif template == 'blog_detail' -%}
        <script>
        window.dotq = window.dotq || [];
        window.dotq.push({
        'projectId': '{{ storeConfig.yahoo_projectid }}',
        'properties': {
        'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
        'qstrings': {
        'et': 'custom',
        'ea': '{{template}}',
        'el': '{{blog.title | escape}}',
        'ev': '{{blog.id}}',
        }
        }
        }); </script>
        {%- elsif template == 'collection_detail' -%}
        <script>
        window.dotq = window.dotq || [];
        window.dotq.push({
        'projectId': '{{ storeConfig.yahoo_projectid }}',
        'properties': {
        'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
        'qstrings': {
        'et': 'custom',
        'ea': '{{template}}',
        'el': '{{collection.title | escape}}',
        'ev': '{{collection.id}}',
        }
        }
        }); </script>
        {%- elsif template == 'page_detail' -%}
        <script>
        window.dotq = window.dotq || [];
        window.dotq.push({
        'projectId': '{{ storeConfig.yahoo_projectid }}',
        'properties': {
        'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
        'qstrings': {
        'et': 'custom',
        'ea': '{{template}}',
        'el': '{{page.title | escape}}',
        'ev': '{{page.id}}',
        }
        }
        }); </script>
    {%- else -%}
            <script>
            window.dotq = window.dotq || [];
            window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
            'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
            'qstrings': {
            'et': 'custom',
            'ea': '{{template}}'
            }
            }
            });</script>
    {%- endif -%}
<script>
    function callback_yahoo_add_to_cart(ecdata) {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'AddToCart',
					'ec': ecdata['ec_data_category'],
                    'gv': ecdata['ec_data_price']*ecdata['ec_data_quantity'],
                    'ev': ecdata['ec_data_quantity'],
                    'product_id': ecdata['ec_data_spu'],

                }
            }
        });
    }

    function callback_yahoo_generate_lead() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'generate_lead',
                }
            }
        });
    }

    function callback_yahoo_login() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'login',
                }
            }
        });
    }

    function callback_yahoo_begin_checkout() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'begin_checkout',
                }
            }
        });
    }

    function callback_yahoo_remove_from_cart(ec_data) {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'remove_from_cart',
					'ec': ec_data['ec_data_category'],
                    'gv': ec_data['ec_data_price']*ec_data['ec_data_quantity'],
                    'ev': ec_data['ec_data_quantity'],
                    'el': ec_data['ec_data_spu'],
                }
            }
        });
    }

    function callback_yahoo_share_product(ec_data, platform) {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'share_product',
					'ec': ec_data['ec_data_category'],
                    'gv': ec_data['ec_data_price']*ec_data['ec_data_quantity'],
                    'ev': ec_data['ec_data_quantity'],
                    'el': ec_data['ec_data_spu'],
                }
            }
        });
    }

    function callback_yahoo_add_address_information() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'add_address_information',
                }
            }
        });
    }

    function callback_yahoo_add_shipping_information() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'add_shipping_information',
                }
            }
        });
    }

    function callback_yahoo_add_payment_information() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'add_payment_information',
                }
            }
        });
    }

    function callback_yahoo_sign_up() {
        window.dotq = window.dotq || [];
        window.dotq.push({
            'projectId': '{{ storeConfig.yahoo_projectid }}',
            'properties': {
                'pixelId': '{{ storeConfig.yahoo_pixel_id }}',
                'qstrings': {
                    'et': 'custom',
                    'ea': 'sign_up',
                }
            }
        });
    }
</script>
<!--End Yahoo Dot -->
        {%- endif -%}


